package com.hotel.system.service.impl;

import com.hotel.common.utils.ShiroUtils;
import com.hotel.system.domain.hotel.HotelInventory;
import com.hotel.system.domain.hotel.HotelInventoryLog;
import com.hotel.system.mapper.SysKcglMapper;
import com.hotel.system.mapper.SysUserPostMapper;
import com.hotel.system.service.ISysKcglService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * 岗位信息 服务层处理
 * 
 * @author hotel
 */
@Service
public class SysKcglServiceImpl implements ISysKcglService
{


    @Autowired
    private SysKcglMapper kcglMapper;

    @Autowired
    private SysUserPostMapper userPostMapper;

    /**
     * 查询岗位信息集合
     * 
     * @param post 岗位信息
     * @return 岗位信息集合
     */
    @Override
    public List<HotelInventory> selectInventoryList(HotelInventory post)
    {
        return kcglMapper.selectInventoryList(post);
    }

    @Override
    public List<HotelInventoryLog> selectInventoryLogList(HotelInventoryLog hotelInventoryLog) {
        return kcglMapper.selectInventoryLogList(hotelInventoryLog);
    }

    /**
     * 通过编码查询库存物料信息
     *
     * @param postId 岗位ID
     * @return 角色对象信息
     */
    @Override
    public HotelInventory selectInventoryCode(String inventoryCode)
    {

        return kcglMapper.selectInventoryCode(inventoryCode);
    }

    /**
     * 修改保存岗位信息
     *
     * @param post 岗位信息
     * @return 结果
     */
    @Override
    public int updateHotelInventory(HotelInventory hotelInventory)
    {
        return kcglMapper.updateHotelInventory(hotelInventory);
    }


    /**
     * 新增保存岗位信息
     *
     * @param post 岗位信息
     * @return 结果
     */
    @Override
    public int insertHotelInventory(HotelInventory hotelInventory)
    {
        hotelInventory.setDeptId(ShiroUtils.getSysUser().getDeptId());
        hotelInventory.setCreateBy(ShiroUtils.getLoginName());
        hotelInventory.setUpdateBy(ShiroUtils.getLoginName());
        hotelInventory.setAdjustId("1");
        hotelInventory.setXykcsl(hotelInventory.getInventoryNumber());
        hotelInventory.setCksl("0");
        return kcglMapper.insertHotelInventory(hotelInventory);
    }

    @Override
    public int insertHotelInventoryLog(HotelInventory hotelInventory) {


//        HotelInventory{id=7, deptId='null', inventoryCode='201_2', inventoryName='鼓风机', inventoryNumber='13', inventorySort='null', status='null', createBy='null', createTime=null,
//        updateBy='null', updateTime=null, remark='测试'}
        HotelInventoryLog hotelInventoryLog = new HotelInventoryLog();
        hotelInventoryLog.setInventoryCode(hotelInventory.getInventoryCode());
        hotelInventoryLog.setInventoryName(hotelInventory.getInventoryName());
        hotelInventoryLog.setAdjustId(hotelInventory.getAdjustId());
        hotelInventoryLog.setAdjustNumberq(hotelInventory.getXykcsl());
        hotelInventoryLog.setAdjustNumber(hotelInventory.getCksl());
        hotelInventoryLog.setAdjustNumberh(hotelInventory.getInventoryNumber());
        hotelInventoryLog.setDeptId(hotelInventory.getDeptId());
        hotelInventoryLog.setCreateBy(ShiroUtils.getLoginName());
        hotelInventoryLog.setUpdateBy(ShiroUtils.getLoginName());
        hotelInventoryLog.setRemark(hotelInventory.getRemark());
        System.out.println(hotelInventoryLog);
        return kcglMapper.insertHotelInventoryLog(hotelInventoryLog);
    }


}
